<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var user = {
            name:'张三',
            age:18,
            gender:'男',
            eat:function(){
                console.log(this.name+'正在吃饭');
            }
        };
        //使用对象
        console.log("姓名："+user.name);
        user.eat();
        //for-in获取对象的属性和值
        for(var temp in user){
            console.log(temp+"="+user[temp]);
        }
//         name=张三 js对象-3自定义.html:23:21
//         age=18 js对象-3自定义.html:23:21
//         gender=男 js对象-3自定义.html:23:21
//         eat=function(){
//                 console.log(this.name+'正在吃饭');
//             }
    </script>
</body>
</html>